package com.liuym.student.repository.mapper;

import com.liuym.common.exception.StudentException;
import com.liuym.student.repository.model.entity.StudentScore;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface StudentScoreMapper {
    int deleteByPrimaryKey(
            @Param("studentScoreTableName") String studentScoreTableName, @Param("id") Integer id);

    int insert(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("record") StudentScore record);

    int insertSelective(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("record") StudentScore record);

    StudentScore selectByPrimaryKey(
            @Param("studentScoreTableName") String studentScoreTableName, @Param("id") Integer id);

    int updateByPrimaryKeySelective(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("record") StudentScore record);

    int updateByPrimaryKey(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("record") StudentScore record);

    /**
     * 根据学号获得分数信息
     *
     * @param studentNumber
     * @return
     */
    List<StudentScore> getStudentScoreByStudentNumber(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("studentNumber") long studentNumber);

    /**
     * 更新分数信息
     *
     * @param studentScore
     * @return
     */
    int updateStudentScore(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("studentScore") StudentScore studentScore);

    /**
     * 删除分数
     *
     * @param id
     * @return
     */
    int deleteStudentScore(
            @Param("studentScoreTableName") String studentScoreTableName, @Param("id") int id);

    /**
     * 删除分数
     *
     * @param id
     * @return
     */
    int deleteStudentScoreByNumber(
            @Param("studentScoreTableName") String studentScoreTableName, @Param("studentNumber") long studentNumber);

    /**
     * 获得一定时间内的分数信息
     *
     * @param studentScoreTableName
     * @param startTime
     * @param endTime
     * @return
     */
    List<StudentScore> getStudentScoreByTime(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("startTime") Date startTime,
            @Param("endTime") Date endTime);

    /**
     * 获得某个管理员操作的分数信息
     *
     * @param studentScoreTableName
     * @param userName
     * @param startTime
     * @param endTime
     * @return
     */
    List<StudentScore> getStudentScoreByAdmin(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("userName") String userName,
            @Param("startTime") Date startTime,
            @Param("endTime") Date endTime);

    /**
     * 批量insert
     *
     * @param list
     */
    int addStudentScoreList(
            @Param("studentScoreTableName") String studentScoreTableName,
            @Param("list") List<StudentScore> list);

    /**
     * 新建学生分数表
     *
     * @return
     */
    int addStudentScoreTable(@Param("studentScoreTableName") String studentScoreTableName) throws Exception;

    /**
     * 查询历史分数
     * @param studentScoreTableName
     * @param studentNumber
     * @return
     */
    List<StudentScore> findHistoryStudentScore(@Param("studentScoreTableName") String studentScoreTableName,@Param("studentNumber") long studentNumber);

    List<String> getStudentScoreTableAll() throws StudentException;
}
